﻿<%@ page title="" language="C#" masterpagefile="~/Training.master" autoeventwireup="true" inherits="Training.Web.Lists.Administration.Catalog.InqueryPelatihanList, App_Web_tml0wt00" %>

<asp:Content ID="ctnBody" ContentPlaceHolderID="body" runat="server">
    <link type="text/css" rel="stylesheet" href="<%= ResolveUrl("~/styles/ui.jqgrid.css") %>" />
    <script type="text/javascript" src="<%= ResolveUrl("~/scripts/i18n/grid.locale-id.js") %>"></script>
    <script type="text/javascript" src="<%= ResolveUrl("~/scripts/jquery.jqGrid.min.js") %>"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.msgBox.v1.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/chosen/chosen.jquery.min.js") %>" type="text/javascript"></script>
    <link href="<%= ResolveUrl("~/styles/chosen/chosen.min.css") %>" rel="stylesheet"
        type="text/css" />
    <div>
        <table border="0">
            <tr>
                <td>
                    Nama Pelatihan
                </td>
                <td>
                    :
                </td>
                <td>
                    <table border="0">
                        <tr>
                            <td>
                                <asp:DropDownList ID="ddlPelatihan" runat="server" Width="300">
                                </asp:DropDownList>
                            </td>
                            <td style="padding-left: 50px;">
                                Tempat Pelatihan
                            </td>
                            <td>
                                :
                            </td>
                            <td>
                                <asp:TextBox ReadOnly="true" ID="txtTempat" runat="server" Width="300"></asp:TextBox>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td>
                    Tgl. Pelatihan
                </td>
                <td>
                    :
                </td>
                <td>
                    <table border="0">
                        <tr>
                            <td style="width:337px;" >
                                <asp:TextBox ReadOnly="true" ID="txtTglPelatihan" runat="server" Width="100"></asp:TextBox>&nbsp;&nbsp;s.d&nbsp;&nbsp;<asp:TextBox ReadOnly="true" ID="txtTglAkhir" runat="server" Width="100"></asp:TextBox>&nbsp;&nbsp;
                            </td>
                            <td style="padding-left: 45px;">
                                Pembicara
                            </td>
                            <td>
                                :
                            </td>
                            <td>
                                <asp:TextBox ReadOnly="true" ID="txtPembicara" runat="server" Width="300"></asp:TextBox>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr id="Tr1" runat="server" visible="false">
                <td colspan="3">
                    <div style="text-align: right; padding-top: 10px;">
                        <button id="btnProcess" type="button">
                            Proses</button>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <br />
    <div style="overflow: auto; height: 350px;">
        <table id="table" class="scroll" cellpadding="0" cellspacing="0">
        </table>
        <div id="pager" class="scroll">
        </div>
        <br />
        <div id="dialog" title="Default dialog">
        </div>
    </div>
    <script type="text/javascript">

        $(document).ready(function () {



            $('#<%= ddlPelatihan.ClientID %>').chosen({ placeholder_text_single: "-- pilih pelatihan --" });
            $('#<%= ddlPelatihan.ClientID %>').change(function () {

                $('#<%= txtTglPelatihan.ClientID %>').val('');
                $('#<%= txtTempat.ClientID %>').val('');
                $('#<%= txtPembicara.ClientID %>').val('');

                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/Administration/catalog/PelatihanLoadHandler.ashx") %>';
                var pelatihanID = $('#<%= ddlPelatihan.ClientID %> option:selected').val();
                if (pelatihanID != "") {

                    $.ajax({
                        type: 'POST',
                        url: handlerUrl + "?method=getbyid&pelatihanID=" + pelatihanID,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (datas) {
                            $('#<%= txtTglPelatihan.ClientID %>').val(datas.TglPelatihan);
                            $('#<%= txtTempat.ClientID %>').val(datas.TempatPelatihan);
                            $('#<%= txtPembicara.ClientID %>').val(datas.Pembicara);


                        },
                        error: function () {
                            $.msgBox("Error load pelatihan  !", null, { title: "Pesan Error" });
                        }
                    });

                    //END
                }

                var pelatihanID = $('#<%= ddlPelatihan.ClientID  %> option:selected').val();
                if (pelatihanID == "")
                    pelatihanID = 0;

                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Administration/Catalog/Pesertahandler.ashx") %>';
                $("#table").jqGrid('setGridParam', { url: handlerUrl + '?method=getdatabypelatihan&pelatihanID=' + pelatihanID });
                $("#table").trigger("reloadGrid");
            });

        });
    </script>
    <script type="text/javascript">
        $("#btnProcess").click(function () {
            var pelatihanID = $('#<%= ddlPelatihan.ClientID  %> option:selected').val();
            if (pelatihanID == "")
                pelatihanID = 0;

            var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Administration/Catalog/Pesertahandler.ashx") %>';
            $("#table").jqGrid('setGridParam', { url: handlerUrl + '?method=getdatabypelatihan&pelatihanID=' + pelatihanID });
            $("#table").trigger("reloadGrid");
        });
    </script>
    <script type="text/javascript">
        $("#btnProcess").button({ icons: { primary: "ui-icon-search"} });
    </script>
    <script type="text/javascript">

        var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Administration/Catalog/Pesertahandler.ashx") %>';
        var pelatihanID = $('#<%= ddlPelatihan.ClientID  %> option:selected').val();
        if (pelatihanID == "")
            pelatihanID = 0;

        $('#table').jqGrid({
            url: handlerUrl + '?method=getdatabypelatihan&pelatihanID=' + pelatihanID,
            datatype: 'json',
            colNames: ['ID', 'NIK', 'Nama Peserta', 'Departemen', 'Bagian', 'Jabatan'],
            colModel: [
                { name: 'PesertaID', key: true, hidden: true, index: 'PesertaID', width: 60 },
                { name: 'NIK', index: 'NIK', align: 'left', width: 100, searchoptions: { sopt: ['cn', 'eq']} },
                { name: 'NamaPeserta', index: 'NamaPeserta', align: 'left', width: 200, searchoptions: { sopt: ['cn', 'eq']} },
                { name: 'Bagian.Department.DepartmentDesc', index: 'Bagian.Department.DepartmentDesc', align: 'left', width: 400, searchoptions: { sopt: ['cn', 'eq']} },
                { name: 'Bagian.NamaBagian', index: 'Bagian.NamaBagian', align: 'left', width: 200, searchoptions: { sopt: ['cn', 'eq']} },
                { name: 'Position.PositionName', index: 'Position.PositionName', align: 'left', width: 200, searchoptions: { sopt: ['cn', 'eq']} }

           	],
            rowNum: 10,
            id: 'PesertaID',
            rownumbers: true,
            rowList: [5, 10, 15, 20],
            pager: '#pager',
            sortname: 'NamaPeserta',
            sortorder: "asc",
            viewrecords: true,
            jsonReader: { repeatitems: false },
            width: 1000,
            height: '100%',
            caption: 'Peserta',
            ajaxGridOptions: { cache: false }
        });

        $("#table").jqGrid('navGrid', '#pager', { edit: false, add: false, del: false, searchtext: 'Search', refreshtext: 'Refresh' },
        {}, {}, {}, { closeOnEscape: true, multipleSearch: true, closeAfterSearch: true });

       
    
    </script>
</asp:Content>
